home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # Start/stop/etc FREESCO in different modes. Called by mode command.
- # This script is responsible for order of executing of other rc_* scripts
-
- . /etc/colors
- . /etc/system.cfg
- . /etc/live.cfg
- . /etc/music.cfg
-
- fn3() { cp /boot/etc/ppp/${1}.opt /etc/ppp/
- echo "name \"$LOGIN\"
- " >>/etc/ppp/${1}.opt
- }
- fn2() { sed -n /^ISPFILE=/P /etc/chat.pwd; }
- fn1() { TMP=$ISPFILE
- [ "$PPPTYPE" = o ] && TMP=PPPoE
- [ "$PPPTYPE" = t ] && TMP=PPtP
- echo "$CM$1 Freesco v$VERSION...$CG Mode $CC $ROUTER $TMP$CW"
- }
- fn() { if [ "$TIMADDR" ]; then
- fork synctime
- fi
- }
- f_pkg() { for i in `ls /pkg/rc/`; do [ -x /pkg/rc/$i ] && /pkg/rc/$i $1; done; }
- stp() {
- [ "`fn2`" ] || return
- echo; fn1 Stopping
- rc_mon $1
- rc_user $1
- f_pkg $1
- rc_diald $1
- rc_lease $1
- rc_ras $1
- killall pppd
- rc_crond $1
- rc_lpd $1
- rc_ident $1
- rc_dhcpd $1
- rc_dns $1
- rc_httpd $1
- rc_ftpd $1
- rc_tlnet $1
- rc_masq $1
- rc_eth $1
- rc_bridg $1
- rc_net $1
- rc_pfwd $1
- }
- str() {
- : >/etc/chat.pwd
- if [ "$2" ]; then
- cat >/etc/live.cfg <<EOF
- ROUTER=$2
- BOOTMOD=$BOOTMOD
- VERSION=$VERSION
- BOOTDEV=$BOOTDEV
- BOOTIME="$BOOTIME"
- EOF
- ROUTER=$2
- fi
- if [ "$ROUTER" = dialup -o "$USEPPP0" = y ]; then
- if [ "$3" ]; then
- ISPFILE=$3
- elif [ "$ROUTER" = ethernet ]; then
- ISPFILE=ethernet
- else
- set -- "`ls /etc/*.isp 2>/dev/null`"
- ISPFILE=`basename "$1" .isp`
- [ -f /etc/${DEFISP}.isp ] && ISPFILE=$DEFISP
- fi
- if [ -f /etc/${ISPFILE}.isp ]; then
- cat /etc/${ISPFILE}.isp > /etc/chat.pwd
- eval `sed -n /PASSWD/P /etc/chat.pwd`
- eval `sed -n /LOGIN/P /etc/chat.pwd`
- echo "\"$LOGIN\" * \"$PASSWD\"
- " >/etc/ppp/pap-secrets
- chmod 600 /etc/ppp/pap-secrets
- if [ "$ROUTER" = ethernet -a "$USEPPP0" = y ]; then
- [ "$PPPTYPE" = o ] && fn3 pppoe
- [ "$PPPTYPE" = t ] && fn3 pptp
- ISPFILE=ethernet
- fi
-
- else
- echo "${CR}Warning ! No ISP account defined, please add one in advanced setup.$CW"
- fi
- fi
- echo "ISPFILE=$ISPFILE" >>/etc/chat.pwd
- fn1 Starting
- set -- start
- if [ "$ROUTER" = bridge ]; then
- rc_bridg $1
- exit
- fi
- rc_net $1
- rc_masq $1
- rc_tlnet $1
- rc_dns $1
- rc_dhcpd $1
- rc_httpd $1
- rc_ftpd $1
- rc_ident $1
- rc_lpd $1
- rc_crond $1
- rc_ras $1
- rc_eth $1
- rc_lease $1
- rc_diald $1
- rc_pfwd $1
- f_pkg $1
- rc_user $1
- rc_mon $1
- if [ "$ROUTER" != dialup ]; then
- fn
- fork dyndns
- fi
- }
- case "$1" in
- boot) rm /etc/ppp/*.opt 2>/dev/null
- for i in `ls boot/kbd/*.gz 2>/dev/null`; do
- [ -f $i ] || break
- echo -n "Loading keyboard map... $CR"
- zcat <$i | loadkmap
- = $? "Done $CC `basename $i .gz`"
- break
- done
- rc_pnp $1
- rc_comm $1
- f_pkg $1
- rc_user $1;;
- start) str $1 $2 $3;;
- stop|halt)stp stop;;
- restart)stp stop; str start $2 $3;;
- newip) rc_eth $1
- rc_masq $1
- rc_dns $1
- rc_pfwd $1
- rc_dhcpd $1
- rc_ras $1
- fn2 $1
- f_pkg $1
- rc_user $1
- fn
- if [ "$ENABEEP" = y ]; then
- play $NEWIP
- fi
- fork dyndns
- ;;
- status) for i in `ls /rc/* /pkg/rc/* 2>/dev/null`; do
- [ -x $i -a "$i" != /rc/rc_main ] && $i status
- echo
- done;;
- esac
-